package com.caiyi.tips.user.mapper;

import com.caiyi.tips.user.bean.ExpertBean;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

@Component("expertMapper")
public interface ExpertMapper {
    @Select("select * from tb_expert where cphone=#{phone, jdbcType=VARCHAR}")
    ExpertBean findExpertByPhone(@Param("phone") String phone);

    @Select("select * from tb_expert where cnickid=#{nickid, jdbcType=VARCHAR}")
    ExpertBean findExpertByNickid(@Param("nickid") String nickid);

    @Select("select count(*) from tb_expert where istate=0 and cphone=#{phone,jdbcType=VARCHAR}")
    int checkExpertExistPhone(@Param("phone") String phone);

    @Select("select count(*) from tb_expert where istate=0 and cnickid=#{nickid,jdbcType=VARCHAR}")
    int checkExpertExistNickid(@Param("nickid") String nickid);

    @Insert("insert into tb_expert(cuserid,cnickid,cphone,cpassword) " +
            "values (#{userid,jdbcType=VARCHAR},#{nickid,jdbcType=VARCHAR},#{phone,jdbcType=VARCHAR},#{password,jdbcType=VARCHAR})")
    int saveExpert(ExpertBean expertBean);
}